import {
  createStoreBindings
} from 'mobx-miniprogram-bindings';
import {store} from '@/store/store'; // 根据你的项目结构调整路径

const storeBindingsBehavior = Behavior({
  properties: {},
  data: {},
  methods: {
    initStoreBindings() {
      this.storeBindings = createStoreBindings(this, {
        store,
        fields: ['token']
      });
    },
  },
  lifetimes: {
    created() {
      console.log('created');
      this.initStoreBindings(); // 初始化 store bindings
    },
    detached() {
      this.storeBindings && this.storeBindings.destroyStoreBindings(); // 销毁 store bindings
    },
  }
});

export default storeBindingsBehavior;